NodeManager={}
NodeManager.name2object={}
NodeManager.object2name={}
NodeManagerFunc={}
NodeManagerFunc.__index=NodeManagerFunc
setmetatable(NodeManager, NodeManagerFunc)

NodeManagerFunc.addObject = function(self,name,obj)
  print("addObject", self,name,obj)
  self.name2object[name] = obj
  self.object2name[tostring(obj)] = name
end

NodeManagerFunc.removeObject = function(self,obj)
  local name=self.object2name[tostring(obj)]
  self.object2name[tostring(obj)] = nil
  self.name2object[name] = nil
end

NodeManagerFunc.removeName = function(self,name)
  local obj=self.name2object[name]
  self.name2object[name] = nil
  self.object2name[tostring(obj)] = nil
end

NodeManagerFunc.getObject = function(self,name)
  return self.name2object[name]
end

NodeManagerFunc.getName = function(self,obj)
  print("getName", self, obj)
  return self.object2name[tostring(obj)]
end

--print(NodeManager)
--t={}
--print(t)
--NodeManager:addObject("test",t)

--print("obj",NodeManager:getObject("test"))
--print("name",NodeManager:getName(t))
